package git.determinal.template.view;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import io.swagger.annotations.ApiModel;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

@ApiModel("查询参数")
@JsonInclude(Include.ALWAYS)
public class QueryParams<T> {
    private T entity;
    private Map<String, Object> params;
    private Collection<OrderField> orders;
    private Collection<MatchField> matchs;

    public T getEntity() {
        return this.entity;
    }

    public Map<String, Object> getParams() {
        return this.params;
    }

    public Collection<OrderField> getOrders() {
        return this.orders;
    }

    public Collection<MatchField> getMatchs() {
        return this.matchs;
    }

    public void setEntity(final T entity) {
        this.entity = entity;
    }

    public void setParams(final Map<String, Object> params) {
        this.params = params;
    }

    public void setOrders(final Collection<OrderField> orders) {
        this.orders = orders;
    }

    public void setMatchs(final Collection<MatchField> matchs) {
        this.matchs = matchs;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof QueryParams)) {
            return false;
        } else {
            QueryParams<?> other = (QueryParams)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label59: {
                    Object this$entity = this.getEntity();
                    Object other$entity = other.getEntity();
                    if (this$entity == null) {
                        if (other$entity == null) {
                            break label59;
                        }
                    } else if (this$entity.equals(other$entity)) {
                        break label59;
                    }

                    return false;
                }

                Object this$params = this.getParams();
                Object other$params = other.getParams();
                if (this$params == null) {
                    if (other$params != null) {
                        return false;
                    }
                } else if (!this$params.equals(other$params)) {
                    return false;
                }

                Object this$orders = this.getOrders();
                Object other$orders = other.getOrders();
                if (this$orders == null) {
                    if (other$orders != null) {
                        return false;
                    }
                } else if (!this$orders.equals(other$orders)) {
                    return false;
                }

                Object this$matchs = this.getMatchs();
                Object other$matchs = other.getMatchs();
                if (this$matchs == null) {
                    if (other$matchs != null) {
                        return false;
                    }
                } else if (!this$matchs.equals(other$matchs)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof QueryParams;
    }

    public int hashCode() {
        boolean PRIME = true;
        int result = 1;
        Object $entity = this.getEntity();
        result = result * 59 + ($entity == null ? 43 : $entity.hashCode());
        Object $params = this.getParams();
        result = result * 59 + ($params == null ? 43 : $params.hashCode());
        Object $orders = this.getOrders();
        result = result * 59 + ($orders == null ? 43 : $orders.hashCode());
        Object $matchs = this.getMatchs();
        result = result * 59 + ($matchs == null ? 43 : $matchs.hashCode());
        return result;
    }

    public String toString() {
        return "QueryParams(entity=" + this.getEntity() + ", params=" + this.getParams() + ", orders=" + this.getOrders() + ", matchs=" + this.getMatchs() + ")";
    }

    public QueryParams(final T entity, final Map<String, Object> params, final Collection<OrderField> orders, final Collection<MatchField> matchs) {
        this.entity = entity;
        this.params = params;
        this.orders = orders;
        this.matchs = matchs;
    }

    public QueryParams() {
    }

    public static class Builder<T> {
        private T entity;
        private Map<String, Object> params;
        private Collection<OrderField> orders;
        private Collection<MatchField> matchs;

        public Builder() {
        }

        public static QueryParams.Builder builder() {
            return new QueryParams.Builder();
        }

        public QueryParams.Builder setEntity(T entity) {
            this.entity = entity;
            return this;
        }

        public QueryParams.Builder setParams(Map<String, Object> params) {
            this.params = params;
            return this;
        }

        public QueryParams.Builder addParam(String key, Object value) {
            if (this.params == null) {
                this.params = new HashMap();
            }

            this.params.put(key, value);
            return this;
        }

        public QueryParams.Builder addOrder(OrderField orderField) {
            if (this.orders == null) {
                this.orders = new ArrayList();
            }

            this.orders.add(orderField);
            return this;
        }

        public QueryParams.Builder addMatch(MatchField matchField) {
            if (this.matchs == null) {
                this.matchs = new ArrayList();
            }

            this.matchs.add(matchField);
            return this;
        }

        public QueryParams<T> build() {
            QueryParams queryParams = new QueryParams();
            queryParams.setEntity(this.entity);
            queryParams.setParams(this.params);
            queryParams.setOrders(this.orders);
            queryParams.setMatchs(this.matchs);
            return queryParams;
        }
    }
}





